import request from '@/utils/request'

// 登录
export const login = (data) => {
    return request({
        url: '/admin-api/system/auth/login',
        method: 'post',
        data
    })
}

// 注册
export const register = (data) => {
    return request({
        url: '/admin-api/system/auth/register',
        method: 'post',
        data
    })
}

// 使用租户名，获得租户编号
export const getTenantIdByName = (name) => {
    return request({
        url: '/admin-api/system/tenant/get-id-by-name?name=' + name,
        method: 'get',
    })
}

// 使用租户域名，获得租户信息
export const getTenantByWebsite = (website) => {
    return request({
        url: '/admin-api/system/tenant/get-by-website?website=' + website,
        method: 'get',
    })
}

// 登出
export const loginOut = () => {
    return request({
        url: '/admin-api/system/auth/logout',
        method: 'post',
    })
}

// 获取用户权限信息
export const getInfo = () => {
    return request({
        url: '/admin-api/system/auth/get-permission-info',
        method: 'get',
    })
}

// 获取登录用户信息
export const getUserInfo = () => {
    return request({
        url: '/admin-api/system/user/profile/get',
        method: 'get',
    })
}

//获取邮箱验证码
export const sendEmailCode = (data) => {
    return request({
        url: '/app-api/system/personalCenter/send-email-code',
        method: 'get',
        params: data
    })
}

//根据邮箱验证码重置密码
export const forgetPassword = (data) => {
    return request({
        url: '/app-api/system/personalCenter/forget-password',
        method: 'put',
        params: data
    })
}

// 短信验证码登录
export const smsLogin = (data) => {
    return request({
        url: '/admin-api/system/auth/sms-login',
        method: 'post',
        data
    })
}

// 社交快捷登录，使用 code 授权码
export function socialLogin(type, code, state) {
    return request({
        url: '/admin-api/system/auth/social-login',
        method: 'post',
        data: {
            type,
            code,
            state
        }
    })
}

// 社交授权的跳转
export const socialAuthRedirect = (type, redirectUri) => {
    return request({
        url: '/admin-api/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri,
        method: 'get',
    })
}
// 获取验证图片以及 token
export const getCode = (data) => {
    return request({
        url: 'system/captcha/get',
        method: 'post',
        data
    })
}

// 滑动或者点选验证
export const reqCheck = (data) => {
    return request({
        url: '/admin-api/system/captcha/check',
        method: 'post',
        data
    })
}

// 通过短信重置密码
export const smsResetPassword = (data) => {
    return request({
        url: '/admin-api/system/auth/sms-reset-password',
        method: 'post',
        data
    })
}


// /admin-api/alert/rules/sendHardAlert 
export const sendHardAlert = (data) => {
    return request({
        url: '/admin-api/alert/rules/sendHardAlert',
        method: 'get',
        params: data
    })
}